<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<script type="text/javascript">
   $(function(){
		$('#user_form').find("input:[name='roleName']").on('afterchange.bjui.lookup', function(e, data) {
			var $name = $("#user_form").find("input:[name=roleName]");
			if($name.val() != ""){
				var array = $name.val().split(",");
				var temp = [];
				var b = false;
				for(var i=0;i<array.length;i++){
					//判断是否重复
					for(var j=0;j<temp.length;j++){
						if(array[i] === temp[j]){
							b = true;
							break;
						}
						b = false;
					}
					if(!b){
						temp.push(array[i]);
					}
				}
				var result = "";
				for(var i=0;i<temp.length;i++){
					if(i == temp.length - 1 ){
						result += temp[i];
						break;
					}
					result += temp[i]+",";
				}
				$name.val(result);
			}
		});
	});

	function user_edit_clearRole(_this) {
		var $this = $(_this);
		$this.parent().find('input').val('');
	}
	
</script>
<div class="bjui-pageContent">
	<form action="user/save.do" id="user_form" data-toggle="validate" data-alertmsg="false">
		<input type="hidden" name="userSn" id="l_userSn" value=" ">
        <table class="table table-condensed" width="100%">
            <tbody>
                <tr>
                    <td style="width: 110px;text-align: right;">
                        <label for="l_loginName" class="control-label x100">登录账号：</label>
                    </td>
                    <td>
                        <input type="text" name="loginName" id="l_loginName" value="" data-rule="required;length[~100];jsvalide" size="20">
                    </td>
                    <td style="width: 110px;text-align: right;">
                        <label for="l_userName" class="control-label x100">用户名称：</label>
                    </td>
                    <td>
                        <input type="text" name="userName" id="l_userName" value="" data-rule="required;length[~64];jsvalide" size="20">
                    </td>
                </tr>
                <tr>
                	<td style="width: 110px;text-align: right;">
                        <label for="l_operatordto_roleName" class="control-label x100">角色：</label>
                    </td>
                	 <td>
							<input type="hidden" name="roleSn" class="doc_lookup" size="5">                
                    		<input readonly="readonly" type="text" data-toggle="lookup" data-title="设置角色" data-url="user/lookUpRole.do?userSn={#l_userSn}" name="roleName" class="doc_lookup" style="width: 200px">
                    		<a href="javascript:" onclick="user_edit_clearRole(this);">清空</a>
                    </td>
                    <td style="width: 110px;text-align: right;">
                    </td>
                    <td>
                    </td>
                </tr>
            </tbody>
        </table> 
    </form>
</div>
<div class="bjui-pageFooter">
	<ul>
		<li><button type="button" class="btn btn-red cancel" data-icon="remove">取消</button></li>
		<li><button type="button" class="btn btn-default save" data-icon="save">保存</button></li>
	</ul>
</div>